//
//  ConfirmNewPublishViewController.m
//  Hui
//
//  Created by HawkingWang on 16/10/28.
//  Copyright © 2016年 Hui. All rights reserved.
//

#import "ConfirmNewPublishViewController.h"
#import "PublishPaymentView.h"//支付View
#import "WebViewController.h"//网页Controller

@interface ConfirmNewPublishViewController ()
@property (weak, nonatomic) IBOutlet UILabel *style;
@property (weak, nonatomic) IBOutlet UILabel *orderTitle;
@property (weak, nonatomic) IBOutlet UILabel *takeName;
@property (weak, nonatomic) IBOutlet UILabel *takeAddress;
@property (weak, nonatomic) IBOutlet UILabel *deliveryName;
@property (weak, nonatomic) IBOutlet UILabel *deliveryAddress;
@property (weak, nonatomic) IBOutlet UILabel *money;

@end

@implementation ConfirmNewPublishViewController
{
    PublishPaymentView *_payView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    [self setInfo];
}

- (void)setInfo{
    _style.text = _styleStr;
    _orderTitle.text = _orderTitleStr;
    _takeName.text = _takeNameStr;
    _takeAddress.text = _takeAddressStr;
    _deliveryName.text = _deliveryNameStr;
    _deliveryAddress.text = _deliveryAddressStr;
    _money.text = _moneyStr;
}

/**派单说明*/
- (IBAction)introduction:(id)sender {
    WebViewController *web = [[WebViewController alloc] init];
    web.titleStr = @"派单说明";
    [self presentViewController:web animated:YES completion:nil];
}
/**支付并发布*/
- (IBAction)publish:(id)sender {
    _payView = [[[NSBundle mainBundle] loadNibNamed:@"PublishPaymentView" owner:nil options:nil] lastObject];
    _payView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    _payView.backgroundColor = RGBACOLOR(0, 0, 0, 0.5);
    _payView.heightConstraint.constant = 113.5 * SCREEN_HEIGHT / 667;
    _payView.money.text = [NSString stringWithFormat:@"¥%@0", _moneyStr];
    [[UIApplication sharedApplication].keyWindow addSubview:_payView];
    
    __weak __typeof__ (PublishPaymentView *)weakView = _payView;
    __weak __typeof__ (self)weakSelf = self;
    _payView.paymentViewClick = ^(int num){
        switch (num) {
            case 0:
                [weakView removeFromSuperview];
                break;
            case 1:
                DLog(@"充值成功");
            {
                [weakView removeFromSuperview];
                [SVProgressHUD showSuccessWithStatus:@"支付成功"];
                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                    [SVProgressHUD dismiss];
                    [weakSelf.navigationController popToRootViewControllerAnimated:YES];
                });
            }
                break;
            default:
                break;
        }
    };
}

- (IBAction)back:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
